<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日期</title>
    <style>
        div{
            width: 300px;
            text-align: center;
            margin: 0 auto;
            padding: 10px 10px;
        }
        #title{
            color: red;
        }
    </style>
</head>
<body>
    <div id="title"></div>
    <div id="date"></div>
    <div id="date2"></div>
  <script>
    var date=new Date()
    var div=document.getElementById("date")
    var div2=document.getElementById("date2")
    console.log(date.getFullYear()+"年")
    console.log((date.getMonth()+1)+"月")
    console.log(date.getDate()+"日")
    // 获取星期几
    console.log("星期"+date.getDay())
    console.log(date.getHours()+"时")
    console.log(date.getMinutes()+"分")
    console.log(date.getSeconds()+"秒")
    // 时间戳
    console.log(date.getTime())
    // 从今天起到2025年国庆倒计时
    function remain_time(){
        var date=new Date()
        var new_date=new Date("2025/10/01 00:00:00")
        var number=new_date-date
        var remain_time=""
        remain_time+=Math.round(number/1000/3600/24)+"天"
        remain_time+=Math.round(number/1000/3600%60)+"时"
        remain_time+=Math.round(number/1000/60%60)+"分"
        remain_time+=Math.round(number/1000%60)+"秒"
        console.log(remain_time)
        div.innerText=remain_time
    }
    function current_time(){
        var date=new Date()
        var current=""
        current+=date.getFullYear()+"年"
        current+=date.getMonth()+1+"月"
        current+=date.getDate()+"日"
        current+=date.getHours()+"时"
        current+=date.getMinutes()+"分"
        current+=date.getSeconds()+"秒"
        div2.innerText=current


    }
    // 倒计时效果实现

    var timer=setInterval(remain_time,1000)
    var timer2=setInterval(current_time,1000)
    // var st=document.getElementsByTagName("button")[0]
    // st.onclick=function (){
    //     // 停止计时
    //     clearInterval(timer)
    // }

    function delay(){
        var title=document.getElementById("title")
        title.innerText="国庆假期倒计时"
    }
    setTimeout(delay,1000)

  </script>
</body>
</html>